﻿using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using AdRotator.Model;

namespace AdDescriptorCreator
{
    class Program
    {
        static void Main(string[] args)
        {
            var settings = new XmlWriterSettings();
            settings.IndentChars = "\t";
            settings.Indent = true;
            var defaultsettings = CreateDefaultAdSettings();
            using (var stream = File.Create("defaultAdSettings.xml"))
            {
                using (var xw = XmlTextWriter.Create(stream, settings))
                {
                    new XmlSerializer(typeof(AdSettings)).Serialize(xw, defaultsettings);
                }
                stream.Close();
            }
        }

        /// <summary>
        /// O
        /// </summary>
        /// <returns></returns>
        public static AdSettings CreateDefaultAdSettings()
        {
            var adSettings = new AdSettings()
            {
                CultureDescriptors = new List<AdCultureDescriptor>()
                {
                    new AdCultureDescriptor()
                    {
                        CultureName = "en-US",
                        AdProbabilities = new List<AdProbability>()
                        {
                            new AdProbability(AdType.PubCenter,35,"test_client","Image480_80",false),
                            new AdProbability(AdType.Smaato,35,"0",null,false),
                            new AdProbability(AdType.AdMob,15,"0",null,false),
                            new AdProbability(AdType.AdDuplex,15,"0",null,false),
                            new AdProbability(AdType.None,0,"0",null,false)
                        }
                    },
                    new AdCultureDescriptor()
                    {
                        CultureName = "en-GB",
                        AdProbabilities = new List<AdProbability>()
                        {
                            new AdProbability(AdType.PubCenter,25,"test_client","Image480_80",false),
                            new AdProbability(AdType.Smaato,25,"0",null,false),
                            new AdProbability(AdType.AdMob,25,"0",null,false),
                            new AdProbability(AdType.AdDuplex,25,"0",null,false),
                            new AdProbability(AdType.None,0,"0",null,false)
                        }
                    },
                    new AdCultureDescriptor()
                    {
                        CultureName = "de-DE",
                        AdProbabilities = new List<AdProbability>()
                        {
                            new AdProbability(AdType.PubCenter,33,"test_client","Image480_80",false),
                            new AdProbability(AdType.AdMob,33,"0",null,false),
                            new AdProbability(AdType.AdDuplex,33,"0",null,false),
                            new AdProbability(AdType.None,0,"0",null,false)
                        }
                    },
                    new AdCultureDescriptor()
                    {
                        CultureName = AdSettings.DEFAULT_CULTURE,
                        AdProbabilities = new List<AdProbability>()
                        {
                            new AdProbability(AdType.Smaato,30,"test_client","Image480_80",false),
                            new AdProbability(AdType.MobFox,10,"0",null,false),
                            new AdProbability(AdType.AdMob,30,"0",null,false),
                            new AdProbability(AdType.AdDuplex,30,"0",null,false),
                            new AdProbability(AdType.None,0,"0",null,false)
                        }
                    }

                    // Here are the other possible descriptors
                    //new AdCultureDescriptor()
                    //{
                    //    CultureName = "fr-FR",
                    //    AdProbabilities = new List<AdProbability>()
                    //    {
                    //        new AdProbability(AdType.PubCenter,50),
                    //        new AdProbability(AdType.AdMob,0),
                    //        new AdProbability(AdType.AdDuplex,50)
                    //    }
                    //},
                    //new AdCultureDescriptor()
                    //{
                    //    CultureName = "it-IT",
                    //    AdProbabilities = new List<AdProbability>()
                    //    {
                    //        new AdProbability(AdType.PubCenter,50),
                    //        new AdProbability(AdType.AdMob,0),
                    //        new AdProbability(AdType.AdDuplex,50)
                    //    }
                    //},
                    //new AdCultureDescriptor()
                    //{
                    //    CultureName = "es-ES",
                    //    AdProbabilities = new List<AdProbability>()
                    //    {
                    //        new AdProbability(AdType.PubCenter,33),
                    //        new AdProbability(AdType.AdMob,33),
                    //        new AdProbability(AdType.AdDuplex,33)
                    //    }
                    //}
                }
            };
            return adSettings;
        }
    }
}
